//
//  AZBaseModel+Map.m
//  AZNetwork
//
//  Created by GorXion on 2018/4/2.
//  Copyright © 2018年 gaoX. All rights reserved.
//

#import "AZBaseModel+Map.h"
#import <YYModel/YYModel.h>

@implementation AZBaseModel (Map)

+ (instancetype)mapObject:(id)response
{
    id result = [response yy_modelToJSONObject];
    if (!result) return nil;
    if (![result isKindOfClass:[NSDictionary class]]) return nil;
    return [self yy_modelWithDictionary:result];
}

+ (NSArray<AZBaseModel *> *)mapArray:(id)response
{
    id result = [response yy_modelToJSONObject];
    if (!result) return nil;
    if (![result isKindOfClass:[NSArray class]]) return @[];
    return [NSArray yy_modelArrayWithClass:self json:response];
}

@end
